#!/usr/bin/perl
#Programmer: Rory Carmichael
#Purpose: Generated a makeflow to run a pvaluelooper.pl job
#Usage: pvaluemfmaker.pl <inputfile>

my $numargs =$#ARGV + 1;
if ($numargs != 1) {
	print STDERR "Usage: pvaluemfmaker.pl <infputfile>\n";
}
my $if = $ARGV[0];
my $numrecords = `cat $if | grep -P '^\$' | wc -l`;
chomp $numrecords;
for (my $i=$numrecords; $i>=0;$i--) {
	print "$if.$i ";
}
print ": splitgenerecords.pl $if\n";
print "\tLOCAL ./splitgenerecords.pl $if\n\n";
for (my $i=$numrecords; $i>=0; $i--) {
	print "$if.$i.out: pvaluelooper.pl $if.$i\n";
	print "\t./rc-clust $if.$i > $if.$i.out\n\n";
}
print "$if.out: cat";
for (my $i=$numrecords; $i>=0;$i--) {
	print " $if.$i.out";
}
print "\n";
print "\tcat";
for (my $i=$numrecords; $i>=0;$i--) {
	print " $if.$i.out";
}
print " > $if.out\n\n";
